<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

use Illuminate\Support\Facades\Route;

Route::get('/', function () {
    return view('welcome');
});
//any语法
//Route::请求方式('请求的URL',匿名函数或控制响应的方法)
Route::any('/test1', function () {
    echo '当前访问的地址是/test1';
});

//match语法
//Route::请求方式([请求类型],'请求的URL',匿名函数或控制响应的方法)
Route::match(['get', ' post'], '/test2', function () {
    echo '当前访问的地址是/test2';
});

//必选参数
Route::any('/test3/{id}', function ($id) {
    echo "当前的用户id是" . $id;
});

//可选参数
Route::any('/test4/{id?}', function ($id = '') {
    echo "当前的用户id是" . $id;
});

//通过?形式传递get参数
Route::any('/test5', function () {
    echo "当前的用户id是" . $_GET['id'];
});

//路由群组
Route::group(['prefix' => 'admin'], function () {
    Route::get('/test1', function () {
    });
    Route::get('/test2', function () {
    });
    Route::get('/test3', function () {
    });
});

//控制器路由写法
Route::get('/home/test/test1', 'TestController@test1');
//分目录处理
Route::get('/home/index/index', 'Home\IndexController@index');
Route::get('/admin/index/index', 'Admin\IndexController@index');

//控制器测试input获取数据
Route::get('/home/test/test2', 'TestController@test2');

//DB门面 增删改查
Route::group(['prefix' => '/home/test'], function () {
    Route::get('add', 'TestController@add');
    Route::get('del', 'TestController@del');
    Route::get('update', 'TestController@update');
    Route::get('select', 'TestController@select');
});
//时间  
Route::get('/home/test/test3', 'TestController@test3');
//循环输出 
Route::get('/home/test/test4', 'TestController@test4');
//模板继承
Route::get('/home/test/test5', 'TestController@test5');
//CSRF验证
Route::get('/home/test/test6', 'TestController@test6');
Route::post('/home/test/test7', 'TestController@test7')->name('test7');

//模型的增删改查
Route::group(['prefix' => '/home/test'], function () {
    Route::any('test8', 'TestController@test8');
    Route::get('test9', 'TestController@test9');
    Route::get('test10', 'TestController@test10');
    Route::get('test11', 'TestController@test11');
    Route::get('test12', 'TestController@test12');
});

//自动认证（二合一方法，自己提交给自己）
Route::any('/home/test/test13', 'TestController@test13');

//文件上传
Route::any('/home/test/test14', 'TestController@test14');

//数据分页
Route::any('/home/test/test15', 'TestController@test15');

//AJAX请求
Route::get('/home/test/test16', 'TestController@test16');
Route::get('/home/test/test17', 'TestController@test17');

//会话控制
Route::get('/home/test/test18', 'TestController@test18');

//缓存操作
Route::get('/home/test/test19', 'TestController@test19');

//联表查询
Route::get('/home/test/test20', 'TestController@test20');
//模型一对一
Route::get('/home/test/test21', 'TestController@test21');
//模型一对多
Route::get('/home/test/test22', 'TestController@test22');
//模型多对多
Route::get('/home/test/test23', 'TestController@test23');
